package cn.itcast.itcaststore.dao.impl;

import cn.itcast.itcaststore.dao.ModifyuserinfoDao;
import cn.itcast.itcaststore.utils.DataSourceUtils;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.ScalarHandler;

import java.sql.SQLException;

/**
 * @Auther: 万秋泊
 * @Date: 2021/11/1 17:03
 * @Description:
 */
public class ModifyuserinfoDaoImpl implements ModifyuserinfoDao {
    private QueryRunner runner = new QueryRunner(DataSourceUtils.getDataSource());

    @Override
    public int updateUserInfo(String username, String password, String sex, String phone) {
        String sql = "UPDATE USER SET PASSWORD=?,gender=?,telephone=? WHERE username=?";
        try {
            return runner.update(sql, password, sex, phone, username);

        } catch (SQLException e) {
            e.printStackTrace();
        }
        return 0;
    }
}
